const app = getApp();
const nt_util = require('../../utils/nt_util.js')
Page({
  data: {
    queryBean: {},
    orderdetail:{},
    productList:{}
  },
  onLoad: function (options) {
    var queryBean = JSON.parse(options.queryBean);
    this.setData({
      queryBean: queryBean
    })
  },
  onShow: function () {
    nt_util.that = this;
    this.getOrderDetail();
  },
  getOrderDetail: function () {
    nt_util.httpRequest(nt_util.api.getOrderDetail, '', {
      orderId: this.data.queryBean.orderId,
    }, function (data) {
      nt_util.that.setData({
        orderdetail: data.data,
        productList: data.data.productList
      })
    });
  },
  cancel: function (event) {
    nt_util.httpRequest(nt_util.api.updateOrderStatus, 'POST', {
      orderId: this.data.queryBean.orderId,
      status:4
    }, function () {
      wx.showToast({
        title: '已成功取消预约',
        icon: 'none',

        success: function () {
          setTimeout(function () {
            wx.navigateBack({
              delta: 5,
            })
          }, 1500);
        }
      })});

  },
  imgYu: function (event) {

    var current = event.currentTarget.dataset.src;


    //图片预览
    wx.previewImage({
      current: current, // 当前显示图片的http链接
      urls: [this.data.queryBean.qrcode] // 需要预览的图片http链接列表
    })
  }
})